package com.julis.activity.setting;

import android.os.Build;
import android.os.Bundle;
import android.support.annotation.RequiresApi;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;

import com.Constant;
import com.baseutils.SpfUtils;
import com.github.czy1121.view.RoundButton;
import com.julis.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 交易时间设置
 */
public class Setting_TradeTime_Activity extends AppCompatActivity {
    @BindView(R.id.img_back)
    RelativeLayout imgBack;
    @BindView(R.id.seekBar)
    SeekBar seekBar;
    @BindView(R.id.layout_ftp)
    RelativeLayout layoutFtp;
    @BindView(R.id.tv_value)
    TextView tvValue;
    @BindView(R.id.activity_seetting)
    LinearLayout activitySeetting;
    @BindView(R.id.setting)
    RoundButton setting;
    int value = 0;

    @RequiresApi(api = Build.VERSION_CODES.O)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_settingtradetime);
        ButterKnife.bind(this);
        int tradetime = (int) SpfUtils.get(this, "tradetime", 1);
        value = tradetime;
        tvValue.setText("当前值：" + tradetime + " S");
        seekBar.setProgress(tradetime - 1);
        seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
                int i = progress + 1;
                tvValue.setText("当前值：" + i + " S");
                value = i;
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {

            }
        });


    }

    @OnClick({R.id.img_back, R.id.setting})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.img_back:
                finish();
                break;
            case R.id.setting:
                String data=  Constant.ManufacturerName+"时间设置成功";
                SpfUtils.put(this, "tradetime", value);
                Toast.makeText(this, data, Toast.LENGTH_SHORT).show();
                break;
        }
    }
}
